<template>
    <div class='main-panel'>
        <div class='menus'>
          <div v-for='(menu,index) in menus' @click='toPage(menu.href)'>
            {{menu.name}}
          </div>
        </div>
        <div style = "padding:20px;width:100%">
          <!-- router-view用于显示子路由 即把匹配到的vue组件显示在当前位置 -->
            <router-view></router-view>  
        </div>
    </div>
    <div class='title'>后台管理系统</div>
  </template>
  
  <script setup lang="ts">
    import { ref, reactive, inject } from 'vue'
    import { useRouter } from 'vue-router'
    import { useJwtStore } from '@/stores/jwt'  //引入jwtStore @符号表示从根目录(src目录)开始

    const jwtStore = useJwtStore()

    //菜单与二级路由
    let menus = [
        {name: '用户管理', href: '/dashboard/user'},
        {name: '文章管理', href: '/dashboard/article'},
        {name: '退出', href: 'logout'},
    ]
    
    let router = useRouter()

    //ts中 String是包装类型 string是基本类型
    function toPage(url:string){
      if(url === 'logout'){
        router.push('/login')
      }else{
        router.push(url)
      }

     
    }

  </script>

  <style scoped lang="scss">
  .main-panel{
    display: flex;
    color: #64676a;
    max-width: 1500px;
    margin: 0 auto;
  }
  .menus{
    padding: 20px 0;
    box-sizing: boarder-box;
    line-height: 55px;
    text-align: center;
    width: 180px;
    height: 95vh;
    boarder-right: 1px solid #dadada;

    // div {
    //     cursor: pointer;  //鼠标移上去变为手
    //     &:hover{
    //       color: #fd760e;
    //     }

    // }
  }

  .meuns > div{
    cursor: pointer;  //鼠标移上去变为手
        &:hover{
          color: #fd760e;
        }
  }

  .title{
    font-size: 65px;
    font-weight: bold;
    text-align: right;
    position: fixed;
    color: rgba(0, 0, 0, 20%);
    right: calc(100vw - 1500px/2);
    bottom: 20px;
  }
    
  </style>
  
  